package blue.starter.httpclient;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * @author Jin Zheng
 * @date 2020-07-08
 */
public interface HttpClient
{
	String METHOD = "GET";

	default StringResponse requestSync(String uri)
	{
		return this.requestSync(uri, METHOD, null, null);
	}

	default StringResponse requestSync(String uri, String method)
	{
		return this.requestSync(uri, method, null, null);
	}

	default StringResponse requestSync(String uri, String method, String body)
	{
		return this.requestSync(uri, method, body, null);
	}

	StringResponse requestSync(String uri, String method, String body, Map<String, String> header);

	default CompletableFuture<StringResponse> requestAsync(String uri)
	{
		return this.requestAsync(uri, METHOD, null, null);
	}

	default CompletableFuture<StringResponse> requestAsync(String uri, String method)
	{
		return this.requestAsync(uri, method, null, null);
	}

	default CompletableFuture<StringResponse> requestAsync(String uri, String method, String body)
	{
		return this.requestAsync(uri, method, body, null);
	}

	CompletableFuture<StringResponse> requestAsync(String uri, String method, String body, Map<String, String> header);

	String getName();

	String getBaseUrl();

	String getUsername();

	String getPassword();

	int getTimeout();

	String getProxy();

	Map<String, String> getHeaders();

}
